<?php
// +----------------------------------------------------------------------
// | title: 标题注释
// +----------------------------------------------------------------------
// | Author: TZ.Leong
// +----------------------------------------------------------------------
// | Date: 2019/7/6 14:46
// +----------------------------------------------------------------------

namespace app\single\model;


use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\db\Where;
use think\exception\DbException;
use think\Model;

class DayOnlineModel extends Model
{
    protected $table = "c_day_online";

    /**
     * 获取最后一个在线数据
     * @param array $where
     * @return mixed
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     */
    public function getOnlineTxt(array $where = array())
    {
        $onlineData = $this->where(new Where($where))->field("stat_project,online_txt")->select();
        $data = array();
        foreach($onlineData as $row){
            $onlineTxtArr = unserialize($row["online_txt"]);
            if(isset($data[$row["stat_project"]])){
                $data[$row["stat_project"]] = arrayMergeSum($onlineTxtArr,$data[$row["stat_project"]]);
            }else{
                $data[$row["stat_project"]] = $onlineTxtArr;
            }
            ksort($data[$row["stat_project"]]);
        }
        return $data;
    }
}